package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.Dept;
import com.qf.entity.UserPosition;
import com.qf.mapper.DeptMapper;
import com.qf.mapper.UserPositionMapper;
import com.qf.service.UserPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.beans.Transient;
import java.util.List;

@Service
public class UserPositionServiceImpl implements UserPositionService {
    @Autowired
    private UserPositionMapper userPositionMapper;
    @Autowired
    private DeptMapper deptMapper;
    @Override
    public PageInfo<UserPosition> findAllInfo(Integer pageNum, Integer size, String postName, String deptName, Integer postStatus) {
        PageHelper.startPage(pageNum,size);
        List<UserPosition> userPositionList = userPositionMapper.selectAllInfo(postName,deptName,postStatus);
        PageInfo<UserPosition> pageInfo = new PageInfo<>(userPositionList);
        return pageInfo;
    }

    @Override
    public List<Dept> findDeptInfo() {
        return deptMapper.selectAll();
    }

    @Override
    @Transient
    public int add(UserPosition userPosition, int[] mid) {
        int count = userPositionMapper.insertSelective(userPosition);

        return count;
    }
}
